package com.jww.service.role;

import com.jww.dao.BaseDao;
import com.jww.dao.role.RoleDao;
import com.jww.dao.role.RoleDaoImpl;
import com.jww.pojo.Role;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class RoleServiceImpl implements RoleService {

    //引入Dao
    private RoleDao roleDao;
    public RoleServiceImpl() {
        roleDao = new RoleDaoImpl();
    }

    //查询角色列表
    @Override
    public List<Role> getRoleList() {
        Connection conn = null;
        List<Role> roleList = new ArrayList<Role>();

        try {
            conn = BaseDao.getConnection();
            roleList= roleDao.getRoleList(conn);
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }finally {
            BaseDao.closeResource(conn, null, null);
        }
        return roleList;
    }
}
